#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int int_tmp(void* p1, void* p2)
{
	return(*(int*)p1 - *(int*)p2);
}
void _swag(void* p1, void* p2,int size)
{
	int i = 0;
	for (i = 0; i < size; i++)
	{
		int tem = *((char*)p1 + i);
		*((char*)p1 + i) = *((char*)p2 + i);
		* ((char*)p2 + i) = tem;
	}
}
void bubble(void* base, int sz, int size, int(*tmp)(void* p1,void* p2))
{
	int i = 0;
	int j = 0;
	for (int i = 0; i < sz-1; i++)
	{
		for (int j = 0; j < sz - i - 1; j++)
		{
			if (tmp((char*)base + j * size, (char*)base + (j + 1)*size) > 0)
			{
				_swag((char*)base + j * size, (char*)base + (j + 1)*size,size);
			}
		}
	}
}
int main()
{
	int arr[] = {1,3,5,7,9,2,4,6,8,0};
	int sz = sizeof(arr) / sizeof(arr[0]);
	bubble(arr, sz, sizeof(int), int_tmp);
	for (int i = 0; i < sz; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}